package com.tedu.springdemo.day04;


import org.springframework.context.annotation.Lazy;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;


@Lazy   //如果没有写@Scope,默认单列模式，这个类需要延迟加载:懒加载
//@Scope("prototype")    //执行:多列模式
@Component
public class UserDao {
    @PostConstruct
    public void myInit(){
        System.out.println("获取数据库连接...");
    }

    public void addUser(){
        System.out.println("创建新用户...");
    }

    public void updateUser(){
        System.out.println("修改用户信息...");
    }


     @PreDestroy
    public void myDestroy(){
        System.out.println("释放数据库...");
    }


}
